package gao;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.annotation.ExcelProperty;

import java.util.ArrayList;
import java.util.List;

public class CreateXLS {
    public static void main(String[] args) {
        String path="F:\\students.xlsx";
        EasyExcel.write(path,Demo.class).sheet("Sheet1").doWrite(data());
    }

    private static List<Demo> data(){
        ArrayList list=new ArrayList();
        Generate generate=new Generate();
        for (int i=0;i<14;i++){
            list.add(new Demo(generate.random_student(),generate.random_problem().getContent()));
        }

        return list;
        /*return new ArrayList(){
            {
                add(new Demo(1,"张三1", 19));
                add(new Demo(2,"张三2", 19));
                add(new Demo(3,"张三3", 19));
                add(new Demo(4,"张三4", 19));
                add(new Demo(5,"张三5", 19));
            }
        };*/
    }

    private static class Demo {
        @ExcelProperty("姓名")
        private String name;
        @ExcelProperty("题目")
        private String question;

        public Demo(String name, String question) {
            this.name = name;
            this.question = question;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getQuestion() {
            return question;
        }

        public void setQuestion(String question) {
            this.question = question;
        }
    }

    /*private static class Demo {
        @ExcelProperty("编号")
        private int id;
        @ExcelProperty("姓名")
        private String name;
        @ExcelProperty("年龄")
        private int age;

        public Demo(int id, String name, int age) {
            this.id = id;
            this.name = name;
            this.age = age;
        }

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }
    }*/

}
